#include("../layout.html")
#@layout("编辑分类目录")

#define dropdown(parents, key, depth, parent)
	#for(x : parents[""+key+""])
		<option #if(x.term_id.equals(parent)) selected="selectd" #end value="#(x.term_id)">#(java.lang.String::join("", java.util.Collections::nCopies(depth, "— ")) + x.name)</option>
		#if(null != parents[""+x.term_id+""])
			#@dropdown(parents, x.term_id, depth+1, parent)
		#end
	#end
#end

#define body()
<h1 class="wp-heading-inline">编辑分类目录</h1>
<hr class="wp-header-end">

<div class="layui-fluid">
	<form class="layui-form tby-form-left" action="/admin/category/update" method="post">
		<input type="hidden" name="term_id" value="#(term.term_id)">
		<div class="layui-form-item">
    		<label class="layui-form-label">名称</label>
    		<div class="layui-input-block" style="width:400px;">
    			<input type="text" name="name" id="name" value="#(term.name??)" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
   	 		</div>
   	 		<p>这将是它在站点上显示的名字。</p>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">别名</label>
    		<div class="layui-input-block" style="width:400px;">
    			<input type="text" name="slug" id="slug" value="#(term.slug??)" placeholder="" autocomplete="off" class="layui-input">
   	 		</div>
   	 		<p>“别名”是在URL中使用的别称，它可以令URL更美观。通常使用小写，只能包含字母，数字和连字符（-）。</p>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">父级分类目录</label>
    		<div class="layui-input-block" style="width:400px;">
    			<select name="parent" id="parent">
    				<option value="0">无</option>
		    		#@dropdown(parents, 0, 0, term.parent??0)
    			</select>
   	 		</div>
   	 		<p>分类目录和标签不同，它可以有层级关系。您可以有一个“音乐”分类目录，在这个目录下可以有叫做“流行”和“古典”的子目录。</p>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">图像描述</label>
    		<div class="layui-input-block" style="width:400px;">
    			<textarea name="description" id="description" placeholder="" class="layui-textarea">#(term.description??)</textarea>
   	 		</div>
   	 		<p>描述只会在一部分主题中显示。</p>
    	</div>
    	<div class="layui-form-item">
   			<button type="submit" lay-submit lay-filter="*" class="layui-btn layui-btn-sm">更新</button>
   		</div>
    </form>
	
</div>
#end

#define foot()
<script>
layui.cache.page = 'category';
</script>
#end